*Replicating Marks et al. 2006 CPS

use "bam_ches_mergedSKJ.dta", clear

regress posi lrecon galtan if year==2002 & east==0 [iweight = vote]
estimates store m1
regress posi lrecon galtan if year==2002 & east==1 [iweight = vote]
estimates store m2


*Generate extremism variables
*"extremism, measured by squaring the distance from the median party on Left/Right and Gal/Tan" 163


**If median is by EU
sum lrecon galtan if year==2002, d

gen lrext=.
gen galtanext=.
replace lrext=(lrecon-5)^2 if year==2002 & east==0
replace lrext=(lrecon-5)^2 if year==2002 & east==1
replace galtanext=(galtan-5.58)^2 if year==2002 & east==0
replace galtanext=(galtan-5.58)^2 if year==2002 & east==1

/**If median is by region
bys east: sum lrecon galtan if year==2002, d

gen lrext=.
gen galtanext=.
replace lrext=(lrecon-4.63)^2 if year==2002 & east==0
replace lrext=(lrecon-5.215)^2 if year==2002 & east==1
replace galtanext=(galtan-6)^2 if year==2002 & east==0
replace galtanext=(galtan-4.735)^2 if year==2002 & east==1

*/

regress posi lrecon galtan lrext galtanext if year==2002 & east==0 [iweight = vote]
estimates store m3

regress posi lrecon galtan lrext galtanext if year==2002 & east==1 [iweight = vote]
estimates store m4

sum lrecon galtan if year==2014, d

replace lrext=(lrecon-5)^2 if year==2014
replace galtanext=(galtan-5.058824)^2 if year==2014

regress posi lrecon galtan if year==2014 & east==0 [iweight = vote]
estimates store m5
regress posi lrecon galtan if year==2014 & east==1 [iweight = vote]
estimates store m6
regress posi lrecon galtan lrext galtanext if year==2014 & east==0 [iweight = vote]
estimates store m7
regress posi lrecon galtan lrext galtanext if year==2014 & east==1 [iweight = vote]
estimates store m8

***BAM TIME!!!!
gen lrext_BAM=.
gen galtanext_BAM=.
replace lrext_BAM=(lrecon_bam--0.016116)^2 if year==2014
replace galtanext_BAM=(galtan_bam-0.0354279)^2 if year==2014

regress eu_bam lrecon_bam galtan_bam if year==2014 & east==0 [iweight = vote]
estimates store m9
regress eu_bam lrecon_bam galtan_bam if year==2014 & east==1 [iweight = vote]
estimates store m10
regress eu_bam lrecon_bam galtan_bam lrext_BAM galtanext_BAM if year==2014 & east==0 [iweight = vote]
estimates store m11
regress eu_bam lrecon_bam galtan_bam lrext_BAM galtanext_BAM if year==2014 & east==1 [iweight = vote]
estimates store m12

#delimit ;
estout m2 m4 m6 m8 m10 m12 using "tableC1.tex", style(tex) cells(b(star fmt(%4.2f)) se(par fmt(%4.2f))) stats(r2 N, fmt(%4.2f %4.0f) labels("\$R^2\$" "N") layout("\multicolumn{1}{c}{@}""\multicolumn{1}{c}{@}")) title("Analyzing Party Position on EU, Western Europe\\Replication and Extension of Marks et al. 2002") varlabels(_cons "Constant" lrecon "Economic Left-Right" galtan "Social Left-Right" lrext "Economic L-R Extremism" galtanext "Social L-R Extremism" lrecon_bam "Economic L-R BAM" galtan_bam "Social L-R BAM" lrext_BAM "Economic L-R Extremism BAM" galtanext_BAM "Social L-R Extremism BAM",) 
starl(\raisebox{.1ex}[0pt]{*} 0.05 \raisebox{.1ex}[0pt]{**} 0.01 \raisebox{.1ex}[0pt]{***} 0.001) eqlabels(none) 
mlabels("2002 Linear" "2002 Nonlinear" "2014 Linear" "2014 Nonlinear" "BAM Linear" "BAM Nonlinear", dep prefix(\multicolumn{@span}{c}{) suffix(})) collab("b (S.E.)", span prefix(\multicolumn{@span}{c}{\text{)suffix(}}))prehead("\begin{sidewaystable}{\caption{\label{t:west}@title}}" "\begin{center}" "\begin{tabular}{lD{.}{.}{4.4}D{.}{.}{4.4}D{.}{.}{4.4}D{.}{.}{4.4}D{.}{.}{4.4}D{.}{.}{4.4}}""\hline") posthead(\hline \hline) prefoot(\hline)  postfoot("\hline""\multicolumn{@span}{l}{{\footnotesize \emph{Note:} * \$p<0.05\$, ** \$p<0.01\$, *** \$p<0.001\$. Ordinary Least squares regressions. Weighted by vote.}}" "\end{tabular}" "\end{center}" "\end{sidewaystable}") replace;

#delimit ;
estout m1 m3 m5 m7 m9 m11 using "tableC2.tex", style(tex) cells(b(star fmt(%4.2f)) se(par fmt(%4.2f))) stats(r2 N, fmt(%4.2f %4.0f) labels("\$R^2\$" "N") layout("\multicolumn{1}{c}{@}""\multicolumn{1}{c}{@}")) title("Analyzing Party Position on EU, Central and Eastern Europe\\Replication and Extension of Marks et al. 2002") varlabels(_cons "Constant" lrecon "Economic Left-Right" galtan "Social Left-Right" lrext "Economic L-R Extremism" galtanext "Social L-R Extremism" lrecon_bam "Economic L-R BAM" galtan_bam "Social L-R BAM" lrext_BAM "Economic L-R Extremism BAM" galtanext_BAM "Social L-R Extremism BAM",) 
starl(\raisebox{.1ex}[0pt]{*} 0.05 \raisebox{.1ex}[0pt]{**} 0.01 \raisebox{.1ex}[0pt]{***} 0.001) eqlabels(none) 
mlabels("2002 Linear" "2002 Nonlinear" "2014 Linear" "2014 Nonlinear" "BAM Linear" "BAM Nonlinear", dep prefix(\multicolumn{@span}{c}{) suffix(})) collab("b (S.E.)", span prefix(\multicolumn{@span}{c}{\text{)suffix(}}))prehead("\begin{sidewaystable}{\caption{\label{t:east}@title}}" "\begin{center}" "\begin{tabular}{lD{.}{.}{4.4}D{.}{.}{4.4}D{.}{.}{4.4}D{.}{.}{4.4}D{.}{.}{4.4}D{.}{.}{4.4}}""\hline") posthead(\hline \hline) prefoot(\hline)  postfoot("\hline""\multicolumn{@span}{l}{{\footnotesize \emph{Note:} * \$p<0.05\$, ** \$p<0.01\$, *** \$p<0.001\$. Ordinary Least squares regressions. Weighted by vote.}}" "\end{tabular}" "\end{center}" "\end{sidewaystable}") replace;

#delimit cr

*Graph
sum
gen anti=0
replace anti=1 if eu_bam<-.5 & year==2014
gen neutral=0
replace neutral=1 if eu_bam>-.5 & eu_bam<.5 & year==2014
gen pro=0
replace pro=1 if eu_bam>.5 & year==2014

twoway (scatter galtan_bam lrecon_bam if east==1 & year==2014 & anti==1, msymbol(square)) (scatter galtan_bam lrecon_bam if east==1 & year==2014 & neutral==1, msymbol(plus)) (scatter galtan_bam lrecon_bam if east==1 & year==2014 & pro==1, msymbol(diamond_hollow)), ytitle(Social Left-Right (BAM)) xtitle(Economic Left-Right (BAM)) scheme(s1mono) legend(on order(1 "Anti" 2 "Neutral" 3 "Pro") rows(1)) note("{it:Note:} {it:n}=141 parties. On the rescaled EU position measure ranging from -1.5 to 1.6, pro- parties have" "a score between 0.5 and 1.6, neutral parties have a score from -0.5 to 0.5, and anti- parties score" "between -1.5 and -0.5.")

graph export "West.pdf", replace

twoway (scatter galtan_bam lrecon_bam if east==0 & year==2014 & anti==1, msymbol(square)) (scatter galtan_bam lrecon_bam if east==0 & year==2014 & neutral==1, msymbol(plus)) (scatter galtan_bam lrecon_bam if east==0 & year==2014 & pro==1, msymbol(diamond_hollow)), ytitle(Social Left-Right (BAM)) xtitle(Economic Left-Right (BAM)) scheme(s1mono) legend(on order(1 "Anti" 2 "Neutral" 3 "Pro") rows(1)) note("{it:Note:} {it:n}=102 parties. On the rescaled EU position measure ranging from -1.5 to 1.6, pro- parties have" "a score between 0.5 and 1.6, neutral parties have a score from -0.5 to 0.5, and anti- parties score" "between -1.5 and -0.5.")

graph export "East.pdf", replace

